#include <REG52.H>
#include "IR.h"
#include "LCD1602.h"

void main()
{
    unsigned int counter;
    unsigned char address, command;
    LCD1602_Init();
    IR_Init();
    LCD1602_ShowString(1, 1, "ADD CMD Counter");
    LCD1602_ShowString(2, 1, "00  00  00000");

    while (1) {

        if (IR_GetReceivedFlag() || IR_GetRepeatFlag()) {

            address = IR_GetAddress();
            command = IR_GetCommand();
            LCD1602_ShowHexNum(2, 1, address, 2);
            LCD1602_ShowHexNum(2, 5, command, 2);

            if (command == IR_VOL_ADD) {
                counter++;
            } else if (command == IR_VOL_MINUS) {
                counter--;
            }
            LCD1602_ShowNum(2, 9, counter, 5);
        }
    }
}
